package com.zfl.thread.day02;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ExecutorServiceDemo04 {
    public static void main(String[] args) {
        ScheduledExecutorService pool = Executors.newScheduledThreadPool(3);
        pool.scheduleWithFixedDelay(()->{
            System.out.println(System.currentTimeMillis());
            System.out.println(Thread.currentThread().getName() + "进来了");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(System.currentTimeMillis());
            System.out.println(Thread.currentThread().getName() + "出来了");
        },2,2, TimeUnit.SECONDS);
    }
}
